package camel.file;

import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.log4j.Logger;

public class FileConvertProcessor  implements Processor {  
	private static Logger logger = Logger.getLogger(FileConvertProcessor.class); 
    @Override  
    public void process(Exchange exchange) throws Exception {  
/*//      Object obj = exchange.getIn().getBody(); //如果是getBody()则返回一个Object  
        //如果是getBody(Class<T>)则返回T类型的实例  
        InputStream body = exchange.getIn().getBody(InputStream.class);  
//      System.out.println("进入:" + body);  
        BufferedReader br = new BufferedReader(new InputStreamReader(body, "UTF-8"));  
          
        StringBuilder sb = new StringBuilder("");  
        String str;  
        while((str = br.readLine()) != null) {  
        	logger.info(str);  
            sb.append(str + "\n");  
        }  
        //exchange.getOut().setHeader(Exchange.FILE_NAME, Exchange.FILE_NAME); 
        exchange.getOut().setHeader(Exchange.FILE_NAME, exchange.getIn().getHeader(Exchange.FILE_NAME));  
          
        exchange.getOut().setBody(sb.toString());  
        logger.info("body:" + exchange.getOut().getBody());  
      }  */
    	String resString = exchange.getOut().getBody(String.class);
    	System.out.println("resString = "+resString);
    	logger.debug("resString = "+resString);;
    }
    }  